import Vue from 'vue'
import Vuex from 'vuex'
import createLogger from 'vuex/dist/logger'
import {host,url,webSocketUrl,resourceTypeMap} from '@/global/config'

Vue.use(Vuex);
export default new Vuex.Store({
	state: {
		//接口前缀
		host,
		//接口集合
		url,
		//页面序列号
		seq: 0,
		//webSocket地址
		webSocketUrl,
		//资源类型
		resourceTypeMap,
		//项目列表
		projectList: [],
		//项目ID-项目名称
		projectMap: new Map(),
		//项目ID-项目所有信息对象
		projectDetailsMap: new Map(),
		//资源地址上传前缀
		resourceHost: null,
		//用户信息
		userInfo:{
			nickName: null,
			avatarUrl: null
		},
		//登录状态
		isLogin: false,
		//登录权限 1 超管 2 企管
		userRole: -1,
		//图片大图显示
		isImageWindowShow: false,
		//图片地址
		imageWindowUrl: null,
		//是否显示网站内容界面
		pageShow: false,
		//Token
		token: "",
		//Token
		userId: 0,
		//浏览器可视高度
		windowVisualHeight: 0,
		//浏览器可视宽度
		windowVisualWidth: 0,
		//内容区高度
		contentHeight: 0,
		//内容区宽度
		contentWidth: 0,
		//顶栏高度-->[配置项]
		headerHeight: 52,
		//底栏高度-->[配置项]
		footerHeight: 70,
		//菜单栏宽度-->[配置项]
		sideWidth: 200,
		//菜单栏实时变化宽度
		realSideWidth: 200,
		//菜单栏宽度
		rightWidth: 0,
		//在线无人机实时遥测Map缓存
		onlineUavMap: new Map(),
		//WebSocket连接
		webSocket:null
	},
	getters: {
		contentHeight: state => {
			return state.windowVisualHeight - state.headerHeight-30;
		},
		rightWidth: state => {
			return state.windowVisualWidth - state.realSideWidth;
		},
		contentWidth: state => {
			return state.windowVisualWidth - state.realSideWidth - 30;
		},
	},
	mutations: {
		setOnlineUavMap(state, param) {//param:{key:*,val:*}
			let val = param.val;
			if (typeof param.val == "object") {
				val = JSON.stringify(val);
			}
			state
		}
	},
	actions: {},
	modules: {},
	strict: false,
	plugins: [createLogger()]
})
